import copy
import re
import warnings
from pathlib import Path
from typing import Literal
import pandas
from ..dataclass.geoProfiles import MaterialTable, ProjectInfo, SectionBore, SectionLine, SectionMaterial
from ..dataclass.results import SingleResult
from ..dataclass.tables import FieldMetadata, TableCollection, TableData
from ..dataclass.terminologies import BoreTypes
from ..dataclass.terminologies import GeoMaterialProps

test_cases: Any
converted: Any

def convert_table_to_material_table(table: TableData, column_name_map: Any = None, map_key_type: Literal[Any, Any] = "title") -> MaterialTable:
    """
    Convert a table to a material table.
    
    Parameters
    ----------
    table: TableData
        The table to convert.
    
    column_name_map: dict[str, GProps] | None, default: None
        The mapping of the column name of the table and the materials name.
        The key is the column name or title of the table and the value is the material name.
        If the mapping of a column is not provided,
        the function will try to find the column with the same name as the value of GeoMaterialProps automatically.
    
    map_key_type: Literal["name", "title"] = "title", default: "title"
        The type of the key of the column_name_map.
        "name" means the name of the column and "title" means the title of the column.
    
    Returns
    -------
    material_table: MaterialTable
        The converted material table.
    """
    ...
def convert_to_project_info(single_result: SingleResult, key_name_map: Any = None) -> ProjectInfo:
    """
    Convert a single result to a project info object.
    
    Parameters
    ----------
    single_result: SingleResult
        The single result to convert.
    
    key_name_map: dict[str, str] | None, default: None
        The mapping of the field_name of the `geoProfiles.ProjectInfo` and field_name or field_title of the single result.
        The key is the field_name in `geoProfiles.ProjectInfo`.
        The value is the field_name or field_title from the single result,
        If the mapping of a key is not provided,
        the function will try to find the field_name of single result which is same as the `geoProfiles.ProjectInfo` field_name automatically.
    
    Returns
    -------
    project_info: ProjectInfo
        The converted project info.
    
    Note
    ----
    This function supports both field_name and field_title from SingleResult.
    It first processes explicit mappings from key_name_map for both field_name and field_title,
    then performs automatic mapping for any unmapped keys.
    """
    ...
def convert_to_section_bores_with_matrials(tables: TableCollection, name_maps: Any = None, selected_bore_nums: Any = None, sample_types_map: Any = None) -> tuple[Any, Any]:
    """
    Convert a collection of tables to section bores and materials.
    
    Parameters
    ----------
    tables: TableCollection
        Collection of tables containing bore, layer, and test data.
    
    name_maps: dict[str, dict[str, str]] | None, default: None
        Mapping of table names and field names between gsc file and the input tables.
        Key is the field_name in the gsc file and value is the table_name or table_title and field_name or field_title in the input tables.
        Example:
        {
            "table_names": {
                "bore_table": "actual_bore_table_name",
                "layer_table": "actual_layer_table_name",
                ...
            },
            "field_names": {
                "bore_table": {
                    "bore_num": "actual_bore_num_field",
                    "x": "actual_x_field",
                    ...
                },
                ...
            }
        }
    
    selected_bore_nums: list[str] | None, default: None
        List of bore numbers to convert. If None, all bores will be converted.
        If provided, only bores with matching bore_num values will be processed.
    
    sample_types_map: dict[str, int] | None, default: None
        Mapping from string sample type names to integer codes.
        For example: {"厚壁原状": 0, "薄壁原状": 0, "扰动样": 1, "岩石样": 2, "水样": 3}
    
    Returns
    -------
    tuple[list[SectionBore], dict[int, SectionMaterial]]
        Tuple containing list of section bores and dictionary of materials.
    
    Note
    ----
    This function supports both field names and field titles for field mappings.
    When a field is mapped in name_maps["field_names"], the function will first
    check if it exists as a field name (column name), and if not found, it will
    check if it exists as a field title. This allows flexible mapping regardless
    of whether you use field names or field titles in your mappings.
    """
    ...
def convert_to_plan_bores(tables: TableCollection, name_maps: Any = None, bore_types_map: Any = None) -> tuple[Any, Any]:
    """
    Convert a collection of tables to section bores and section lines for plan drawing.
    
    Parameters
    ----------
    tables: TableCollection
        Collection of tables containing bores and section lines data.
    
    name_maps: dict[str, dict[str, str]] | None, default: None
        Mapping of table names and field names between gsc file and the input tables.
        Key is the field_name in the gsc file and value is the table_name or table_title and field_name or field_title in the input tables.
        Example:
        {
            "table_names": {
                "bore_table": "actual_bore_table_name",
                "layer_table": "actual_layer_table_name",
                "section_line_table": "actual_section_line_table_name",
                ...
            },
            "field_names": {
                "bore_table": {
                    "bore_num": "actual_bore_num_field",
                    "x": "actual_x_field",
                    "y": "actual_y_field",
                    "bore_type": "actual_bore_type_field",
                    "top": "actual_top_field",
                    "steady_water_depth": "actual_steady_water_depth_field",
                },
                "layer_table": {
                    "bore_num": "actual_bore_num_field",
                    "depths": "actual_depths_field"
                },
                "section_line_table": {
                    "name": "actual_name_field",
                    "bores": "actual_bores_field",
                }
            }
        }
    
    bore_types_map: dict[str, BoreTypes] | None, default: None
        Mapping from string bore type names to BoreTypes enum.
        For example: {"鉴别孔": BoreTypes.IdentificationBore, "取土试样钻孔": BoreTypes.SoilSamplingBore}
        If the map is not specified, will try to compare to the values and titles of BoreTypes automatically.
    
    Returns
    -------
    tuple[list[SectionBore], list[SectionLine]]
        Tuple containing list of section bores and list of section lines.
    
    Note
    ----
    This function supports both field names and field titles for field mappings.
    When a field is mapped in name_maps["field_names"], the function will first
    check if it exists as a field name (column name), and if not found, it will
    check if it exists as a field title. This allows flexible mapping regardless
    of whether you use field names or field titles in your mappings.
    """
    ...
def latex_to_unicode(text):
    """
    Convert LaTeX-style superscripts, subscripts, and symbols to Unicode characters.
    
    Examples:
        H_{2}O -> H₂O
        x^{2} -> x²
        E = mc^{2} -> E = mc²
        \alpha_{1} -> α₁
        CO_{2} -> CO₂
        x^{n+1} -> xⁿ⁺¹
    
    Args:
        text (str): Text containing LaTeX notation
    
    Returns:
        str: Text with Unicode characters
    """
    ...
def convert_tables_names(tables_original: TableCollection, map_tables_df: Any = None, map_file: Any = None) -> TableCollection:
    """
    通过映射文件，转换初始表的名称和字段名称
    
    Parameters
    ----------
    tables_original: TableCollection
        The initial tables
    
    map_tables_df: pd.DataFrame | None, default: None
        The mapping tables, DataFrame.
        If not None, `map_file` will be ignored.
    
    map_file: str | Path | None, default: None
        The mapping file, csv format
    
    Returns
    -------
    TableCollection | None
        The converted tables
    """
    ...

class LaTeXToUnicodeConverter:
    def __init__(self):
        ...
    def convert_superscript(self, text):
        """Convert LaTeX superscript notation to Unicode superscripts"""
        ...
    def convert_subscript(self, text):
        """Convert LaTeX subscript notation to Unicode subscripts"""
        ...
    def convert_symbols(self, text):
        """Convert LaTeX symbol notation to Unicode symbols"""
        ...
    def convert_latex_to_unicode(self, text):
        """Main function to convert LaTeX notation to Unicode"""
        ...
